#!/usr/bin/python
# plot_EstimateDependence.py

import math
import numpy
from matplotlib import use as useBackend
useBackend('Agg')
import matplotlib.pyplot as ppt


def cheat111():
    '''Cheat to clear the plot.'''
    ppt.subplot(311)
    ppt.plot([0,1],[1,2])
    ppt.subplot(131)
    ppt.plot([0,1],[1,2])
    ppt.subplot(111)


def plot(simpars, phypars, EDtuple):
    '''Shows GM_EstimateDependence's results.'''
    for i in simpars:
        cmd = "%s = simpars['%s']" % (i,i)
        exec cmd
    for i in phypars:
        cmd = "%s = phypars['%s']" % (i,i)
        exec cmd
    (numberlist, distancelist, vtapplist, proptolist) = EDtuple
    speedstring = str(bulk_vels[1]*kmperpc/secperyear) # pc/yr -> km/s
    cheat111()
    ppt.subplot(221)
    titlestring = "Rate scaling estimation for a rotational velocity of "+speedstring+" km/s"
    ppt.title(titlestring)
    ppt.semilogy(MvVals,numberlist,marker='.')
    ppt.xlabel('Apparent Mv')
    ppt.ylabel('Total number of stars')
    ppt.subplot(222)
    ppt.semilogy(MvVals,distancelist,marker='.')
    ppt.xlabel('Apparent Mv')
    ppt.ylabel('Estimated typical source distance')
    ppt.subplot(223)
    ppt.semilogy(MvVals,vtapplist,marker='.')
    ppt.xlabel('Apparent Mv')
    ppt.ylabel('Estimated typical angular velocity')
    ppt.subplot(224)
    ppt.semilogy(MvVals,proptolist,marker='.')
    ppt.xlabel('Apparent Mv')
    ppt.ylabel('Estimated rate scaling')
    filestring = "RateScaleEst_"+speedstring+".pdf"
    ppt.savefig(filestring)
